package demo.oscache;

/**
 * oscache 数据缓存测试
 * 
 * @author hemj
 * @date 2016年11月15日
 */
public class TestObjectCache {

	public static void main(String[] args) {
		UserCacheManager cm = UserCacheManager.getInstance();
		TestObjectCache test = new TestObjectCache();
		test.print(cm);
	}

	public void print(UserCacheManager cm) {
		User user = new User(1);
		System.out.println("add[1]: " + user);
		cm.putUser(user);

		user = new User(1);
		System.out.println("add[2]: " + user);
		cm.putUser(user);

		user = cm.getUser(1);
		System.out.println("get[1]: " + user);

		System.out.println("remove[1]");
		cm.removeUser("1");

		user = cm.getUser(1);
		System.out.println("get[1]: " + user);

		System.out.println("sleep ... ");
		try {
			Thread.sleep(5000);
		} catch (Exception e) {
		}
		user = cm.getUser(2);
		System.out.println("get[2]: " + user);

		System.out.println("remove[2]");
		cm.removeUser("2");

		System.out.println("removeAll");
		cm.removeAllNews();
	}
}